<template>
  <div>

    <h2>一、发送get请求</h2>
    <h3>1、get请求</h3>
    <div>
      <el-button @click="getClick()" type="primary">get请求一</el-button>
      <span>{{response}}</span>
    </div>

    <div>
      <el-button @click="getClick2()" type="success">get请求二</el-button>
    </div>

    <h3>2、post请求</h3>
    <el-button type="primary" @click="postClick()">post请求</el-button>
    <div>

      <h2>二、封装后发送请求</h2>
      <h3>1、发送get请求</h3>
      <el-button type='primary' @click="getClicker()">get请求</el-button>
      <h3>2、发送post请求</h3>
      <el-button type='success' @click="getClickPost()">post请求</el-button>

    </div>

  </div>
</template>

<script>
import axios from 'axios'
import request from '@/utils/request'
import NProgress from 'nprogress' // Progress 进度条
import 'nprogress/nprogress.css'// Progress 进度条样式
export default {
  name: 'ax',
  data () {
    return {
      response: {},

    }
  },

  methods: {
    getClick () {
      let self = this
      axios.get('http://39.100.139.181:8080/prod-api/aitest/project/list?item=1').then(function (response) {
        self.response = response
        console.log(response)
      })
    },

    getClick2 () {
      let self = this
      axios.get('http://39.100.139.181:8080/prod-api/aitest/project/list', { params: { item: 1 } }).then(function (response) {
        self.response = response

      })
    },

    postClick () {
      let self = this
      axios.post('http://qa.kanzhun-inc.com/boss/interface/add', {
        projectId: 2,
        groupId: 79,


      }).then(function (response) {
        console.log(response)

      })

    },

    getClicker () {
      let self = this
      request({
        url: "/prod-api/aitest/project/list?item=1",
        method: "get",
        params: ""
      }).then(resp => {
        self.response = resp
      });
    },

    getClickPost () {
      request({
        url: "/aitest/interface/add",
        method: "post",
        params: {}
      }).then(resp => {
        this.response = resp


      });
    }


  },
  mounted () {
    NProgress.start()
  },
}
</script>

<style scoped>
</style>